public class LeetCode171 {

    public static void main(String[] args) {
        String columnTitle = "AA";

        System.out.println(titleToNumber(columnTitle));
    }

    public static int titleToNumber(String columnTitle) {
        int res = 0;
        for (int i = 0; i < columnTitle.length(); i++) {
            char c = columnTitle.charAt(i);
            int num = c - 'A' + 1;
            res = res * 26 + num;
        }
        return res;
    }

}
